package com.ruoyi.exam.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamArrangement;
import com.ruoyi.exam.service.IExamArrangementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补缓考安排管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/exam/makeupArrange")
public class ExamArrangementController extends BaseController
{
    @Autowired
    private IExamArrangementService examArrangementService;

    /**
     * 查询补缓考安排管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupArrange:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamArrangement examArrangement)
    {
        startPage();
        List<ExamArrangement> list = examArrangementService.selectExamArrangementList(examArrangement);
        return getDataTable(list);
    }

    /**
     * 导出补缓考安排管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupArrange:export')")
    @Log(title = "补缓考安排管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamArrangement examArrangement)
    {
        List<ExamArrangement> list = examArrangementService.selectExamArrangementList(examArrangement);
        ExcelUtil<ExamArrangement> util = new ExcelUtil<ExamArrangement>(ExamArrangement.class);
        util.exportExcel(response, list, "补缓考安排管理数据");
    }

    /**
     * 获取补缓考安排管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupArrange:query')")
    @GetMapping(value = "/{arrangeId}")
    public AjaxResult getInfo(@PathVariable("arrangeId") Long arrangeId)
    {
        return success(examArrangementService.selectExamArrangementByArrangeId(arrangeId));
    }

    /**
     * 新增补缓考安排管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupArrange:add')")
    @Log(title = "补缓考安排管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamArrangement examArrangement)
    {
        return toAjax(examArrangementService.insertExamArrangement(examArrangement));
    }

    /**
     * 修改补缓考安排管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupArrange:edit')")
    @Log(title = "补缓考安排管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamArrangement examArrangement)
    {
        return toAjax(examArrangementService.updateExamArrangement(examArrangement));
    }

    /**
     * 删除补缓考安排管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupArrange:remove')")
    @Log(title = "补缓考安排管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{arrangeIds}")
    public AjaxResult remove(@PathVariable Long[] arrangeIds)
    {
        return toAjax(examArrangementService.deleteExamArrangementByArrangeIds(arrangeIds));
    }
}
